<template>
  <div class="main ub ub-ver">
    <NavBar title="无坐标客户" />
    <div v-if="dataList.length > 0" class="content ub-f1">
      <radio-group @change="radioChange">
        <div v-for="(item,index) in dataList" :key="index" class="cell ub ub-ac bbc">
          <div class="tit ub-f1">{{ item.custName }}</div>
          <radio :value="item.id" color="#3387FF" :checked="item.id == current" />
        </div>
      </radio-group>
      <button form-type="submit" type="primary" class="btn" @click="submit">更新坐标</button>
    </div>
    <div v-else class="content ub-f1 ub ub-ver ub-ac ub-pc">
      <image class="nodataImg" src="../../static/null/null3.png" mode="widthFix" />
      <div class="nodataTxt">暂无客户</div>
    </div>
  </div>
</template>
<script>
import service from '@/utils/http'
import constant from '@/utils/constant'
import { errDialog, loading, toPage } from '@/utils/util'
export default {
  data() {
    return {
      curTab: 0,
      current: '',
      dataList: [],
      toPage
    }
  },
  onReady() {
    this.getData()
  },
  methods: {
    getData() {
      service.post('/app/cust/getByNoLatLon').then(res => {
        this.dataList = res.data
      })
    },
    radioChange(e) {
      this.current = e.target.value
    },
    submit() {
      uni.getLocation({
        type: 'gcj02',
        success: (res) => {
          const longitude = String(res.longitude)
          const latitude = String(res.latitude)
          service.post('/app/cust/updatePoint', { longitude, latitude, id: this.current }).then(res => {
            uni.showToast({ title: '更新坐标成功', icon: 'none' })
            uni.navigateBack()
          })
        },
        fail: () => {
          console.log('error')
        }
      })
    }
  }
}
</script>
<style scoped>
.main {
  position: relative;
  width: 100%;
  height: 100%;
}
.content{
  width: 100%;
  border-radius: 16rpx 16rpx 0 0;
  background: #ffffff;
  overflow: hidden;
  position: relative;
  z-index: 1;
  padding: 0 20rpx;
  overflow: auto;
}
.sTit{font-size: 28rpx;color: #333;padding-left:10rpx;font-weight: bold;}
.cell {
  height: 100rpx;
  background: #fff;
}
.tit {
  font-size: 28rpx;
  color: #333;
  margin-right: 20rpx;
}
.bbc {
  border-bottom: 1rpx #eee solid;
}

.btn1{
  width:600rpx;
  height:130rpx;
  line-height: 130rpx;
  font-size: 36rpx;
  color: #FFFFFF;
  background-color: #3387FF;
  margin-bottom:50rpx
}
</style>
